<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<%@include file="/WEB-INF/jsp/common/taglib.jsp"%>
<script type="text/javascript">
	$(function(){
		$.ajax({
			url:'${ctx}/resources/getResourcesAll.shtml',
			dataType:'json',
			type:'post',
			success:function (data){
				var pid = document.getElementById("parentid");
				pid.innerHTML="";
				pid.options[0] = new Option("顶级目录",0);
				if(data!=null){
					for (i = 0; i < data.length; i++) {
						pid.options[i+1] = new Option(data[i].name,data[i].id);
					}
				}
			}
		});
		$("#save").click("click",function(){
			$("#add").ajaxSubmit({
				type:'post',
				dataType:'json',
				success:function(result){
					if(result){
						opener.loadList();
						close();
					}
				}
			})
		});
		$("#close").click("click",function(){
			close();
		});
	}) 
</script>
</head>
<body>
	<form action="${ctx }/resources/add.shtml" id="add" name="add" method="post">
		<input type="hidden" name="type" value="1">
		<div>
			<label>名称：</label>
			<input type="text" id="name" name="name">
			<br>
			<br>
			<label>URL：</label>
			<input type="text" id="resurl" name="resurl"/>
			<br>
			<br>
			<label>父节点：</label>
			<select id="parentid" name="parentid">	
			</select>
		</div>
		<br>
		<div>
			<input type="button" id="save" value="提交">&nbsp;&nbsp;&nbsp;
			<input type="button" id="close" value="关闭"/>
		</div>
	</form>
</body>
</html>